package main

import (
	"k8s.io/client-go/discovery"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
)

type Clients struct {
	config          *rest.Config
	clientSet       kubernetes.Interface
	discoveryClient discovery.DiscoveryInterface
}

func NewClients() (clients Clients) {
	config, err := clientcmd.BuildConfigFromFlags("", "/home/cloudea/.kube/config")
	if err != nil {
		return
	}

	clients.config = config
	clients.clientSet, err = kubernetes.NewForConfig(config)
	if err != nil {
		return
	}

	clients.discoveryClient, err = discovery.NewDiscoveryClientForConfig(config)
	if err != nil {
		return
	}

	return
}

func (c *Clients) ClientSet() kubernetes.Interface {
	return c.clientSet
}

func (c *Clients) DiscoveryClient() discovery.DiscoveryInterface {
	return c.discoveryClient
}

func (c *Clients) GetConfig() *rest.Config {
	return c.config
}
